package util

import (
	"fmt"
	"runtime"
	"strings"
)

func GetStrackText(skip int) string {
	pc, file, line, ok := runtime.Caller(skip)
	pcName := runtime.FuncForPC(pc).Name()
	if !ok {
		file = "???"
		line = 1
	} else {
		slash := strings.LastIndex(file, "/")
		if slash >= 0 {
			file = file[slash+1:]
		}
	}
	return fmt.Sprintf("[file:%s] [line:%d][%s]", file, line, pcName)
}